using System.Linq;
using System.Collections.Generic;

namespace Sustainalytics.ESGRatings.Computing.Service.Validators
{
    public interface IValidator<in T>
    {
        ICollection<string> BrokenRules(T entity);

        bool IsValid(T entity);
    }

    public abstract class Validator<T> : IValidator<T>
    {
        protected List<string> BrokenRulesList { get; private set; }

        protected Validator()
        {
            this.BrokenRulesList = new List<string>();
        }

        public abstract ICollection<string> BrokenRules(T entity);
       

        public bool IsValid(T entity)
        {
            return this.BrokenRules(entity).Any();
        }
    }
}